This application claims the priority of Korean Patent Application No. 2002-44301, filed on Jul. 26, 2002, in the Korean Intellectual Property Office, the disclosure of which is incorporated herein in its entirety by reference.
1. Field of the Invention
The present invention relates to a method for managing a flash memory, a method for leveling the wear of blocks in a flash memory, and a method for managing a file system for a flash memory.
2. Description of the Related Art
A flash memory is a type of highly-integrated nonvolatile memory that can be electrically erased and reprogrammed. The flash memory has not only the advantage of a read only memory (ROM) that can be freely recorded and deleted, but also the advantage of a random access memory (RAM) that can save stored data even when power is removed. Thus, these days, the flash memory is widely used as a storage medium in portable electronic products such as digital cameras, personal digital assistants (PDAs), or MP3 players.
The flash memory is very different from other existing memory in that memory data are changed through electrical erasure and programming and this changing of memory data is non-atomic. In an initial state, each bit of a flash memory has a value of 1. Also, in order to record data in a predetermined location, one bit can be changed from 1 to 0. However, a bit recorded as 0 cannot be restored to 1. Thus, in order to change data recorded in a predetermined location, only when a predetermined amount of a memory block containing a corresponding location is reinitialized to 1 after undergoing electrical erasure, data can be recorded again.
When a file system performs a write operation directly using a physical address of the flash memory without performing a predetermined function of mapping blocks, memory required to map blocks can be saved. However, in this case, due to the non-atomic characteristics of changing of the flash memory, problems occur. That is, when errors occur before new data are recorded after a corresponding memory block is electrically erased so as to change data recorded in a predetermined location, existing data are not left in the corresponding memory block, new data are not recorded in the corresponding memory block, and different data remain in the corresponding memory block. However, an existing file system cannot master this situation caused by the non-atomic characteristics.
Thus, a flash translation layer (FTL) which is a software unit for mapping blocks so that a file system can use a flash memory as a block unit such as a hard disc, is required. A layer 100 of a file system for a flash memory including an FTL is schematically shown in FIG. 1.
When a file system 110 provides information on a logical location of a corresponding file to an FTL 120, the FTL 120 translates the information on the logical location provided by the file system 110 into information on a physical location of the corresponding file using mapping information. Also, when the FTL 120 requests a device driver 130 to work on the corresponding file using the information on the physical location of the corresponding file, the device driver 130 performs an operation on a file recorded in a flash memory 140 using the information on the physical location of the corresponding file.
The flash memory 140 has a structure composed of blocks and pages. The sizes of a block and a page may be determined by each product using the flash memory. As an example, a flash memory having a size of 16 megabytes, a block size of 16 kilobytes, and a page size of 512 bytes includes 1024 blocks, and each of the blocks includes 32 pages. In this case, recording and reading of data is performed in units of pages, and electrical erasure is executed in units of blocks.
However, as the capacity of the flash memory becomes larger, the memory portion required to map blocks performed by the FTL increases.
The structure of a conventional flash memory is shown in FIG. 2A. A mapping table of data and mapping information of a data block is recorded in a flash memory 200. The mapping table is distributed over several blocks of the flash memory and includes a first mapping table 210, a second mapping table 220, a third mapping table 230, and a fourth mapping table 240. Likewise, since mapping information of a data block is distributed over several blocks of the flash memory, in order to read or write data, the entire mapping table should be made by adding a plurality of mapping tables distributed over the flash memory 200 to one another, as shown in FIG. 2B. Thus, in order to perform a flash memory operation in the prior art, the entire mapping table should be made such that an operational time is delayed. Also, since mapping information of all data should be included in the mapping table, the size of the mapping table increases, thereby wasting a large portion of the flash memory.
Each block in the flash memory wherein data can be recorded has a limited life span. The life span has a close relationship with the number of electrical erasures executed in each block. That is, when the number of electrical erasures increases over a predetermined number, problems may occur when data are recorded. The number of electrical erasures is generally limited to a hundred thousand through a million and determined by each product using the flash memory.
When electrical erasures are executed repeatedly only in a particular block, only the life span of the particular block is shortened, and thus, data cannot be recorded in that block any more. Thus, a method for leveling the wear of blocks in a flash memory, by which electrical erasures are prevented from being repeatedly executed only in a particular block and performed uniformly in all blocks such that the life spans of all blocks are the same, has been proposed.
In an existing method for leveling the wear of blocks in a flash memory, information on the number of electrical erasures in all data blocks of the flash memory is maintained in each data block of the flash memory, thereby causing a waste of memory capacity, making it difficult to manage the memory, and causing functional overhead.